<?php
// +----------------------------------------------------------------------
// | EasyAdmin
// +----------------------------------------------------------------------
// | PHP交流群: 763822524
// +----------------------------------------------------------------------
// | 开源协议  https://mit-license.org 
// +----------------------------------------------------------------------
// | github开源项目：https://github.com/zhongshaofa/EasyAdmin
// +----------------------------------------------------------------------
namespace app\model\api;

use laytp\BaseModel;
use think\model\concern\SoftDelete;

class YysYh extends BaseModel
{
    protected $name = 'yys_yh';

    /**
     * 角色御魂详情
     * @param $role_id
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function detail($role_id){
        $list = $this->where('role_id','=',$role_id)
            ->field('ico,main_attr1,main_attr2,recomm_reason')
            ->cache(true)->select()->toArray();

        if(empty($list)){
            return [];
        }

        array_walk($list,function(&$item,$key){
            $item['ico'] = json_decode($item['ico'],true);
            $item['main_attr1'] = json_decode($item['main_attr1'],true);
            $item['main_attr2'] = json_decode($item['main_attr2'],true);
        });

        return $list;

    }
}